import request from '@/utils/request'
const api = {
  phoneCaptcha: '/api/auth/phoneCaptcha',
  phoneToken: '/api/auth/phonetoken',
  listMyOrder: '/api/order/listMyOrder',
  orderDetail: '/api/order/detail',
  updateSelf: '/api/order/updateSelf',
  getisRange: '/api/xmbz-order/orderGroupLink/open/isRange',
  getSelfDelivery: '/api/order/getDeptList',
  getAssistant: '/api/order/open/getAssistant',
  getOrderById: '/api/xmbz-order/orderGroupLink/open/getOrderById',
}

// 获取手机验证码
export function phoneCaptcha(params) {
  return request({
    url: api.phoneCaptcha,
    method: 'get',
    params,
  })
}

// 根据手机验证码获取token
export function phoneToken(params) {
  return request({
    url: api.phoneToken,
    method: 'post',
    params,
  })
}

// 获取订单列表
export function listMyOrder(params) {
  return request({
    url: api.listMyOrder,
    method: 'get',
    params,
  })
}

// 获取订单详情
export function orderDetail(params) {
  return request({
    url: api.orderDetail,
    method: 'get',
    params,
  })
}

// 更新订单
export function updateOrder(data) {
  return request({
    url: api.updateSelf,
    method: 'post',
    data,
    noErrorTip: true
  })
}

// H5获取自提城市列表
export function getSelfDelivery(params) {
  return request({
    url: api.getSelfDelivery,
    method: 'get',
    params,
  })
}

export function getisRange(params) {
  // H5根据经纬度查询地址是否在配送范围
  return request({
    url: api.getisRange,
    method: 'get',
    params,
  })
}

// 输入提示
export const getAssistant = (query) => {
  return request({
    url: api.getAssistant,
    method: 'get',
    params: query
  })
}
